package com.itheima.reggie.web.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//点菜端菜品的表现层控制器
@RestController
@RequestMapping("/dish")
public class DishController {

    @Autowired
    private DishService dishService;

    //点餐端根据分类id和状态码查询菜品列表
    @GetMapping("/list")
    public ResultInfo findByCategoryIdAndStatus(Long categoryId,Integer status) {
        //调用service
        List<Dish> dishList = dishService.findByCategoryIdAndStatus(categoryId, status);
        //返回
        return ResultInfo.success(dishList);
    }
}